import cv2
import time
from utils import handsutils
from utils.handservo import handServo

def main():
  cap = cv2.VideoCapture(0)
  previous_time_fps = 0
  dirver=handServo()

  while cap.isOpened():
    current_time = time.time()
    success, image = cap.read()
    if not success:continue
    image = handsutils.mediapipe_gestures(cv2.flip(image, 1),dirver)
    fps = 1 / (current_time - previous_time_fps)
    previous_time_fps = current_time
    cv2.putText(image, f"{int(fps)} FPS", (10, 30), cv2.FONT_HERSHEY_PLAIN, 2, (255, 0, 0), 2)
    cv2.imshow('MediaPipe Hands', image)
    if cv2.waitKey(5) & 0xFF == 27:break
  cap.release()

if __name__ == '__main__':
    main()
